Skip to content
This repository has been archived by the owner on Sep 12, 2024. It is now read-only.

Add max_connections to OfferRequest creation #213

Merged
merged 2 commits into from
Jan 25, 2023

Conversation

JamesWair
Copy link
Contributor

This PR adds the max_connections parameter to the OfferRequest create request.

@staticmethod
def _validate_max_connections(max_connections):
"""Validate the max connection number"""
if max_connections < 0:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we only support integers in the API, I wonder if we should:

Suggested change
if max_connections < 0:
if isinstance(max_connections, int) and max_connections < 0:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good shout! Assuming isinstance returns True in this case when it is an int, I think we would want:
if not isinstance(max_connections, int) or max_connections < 0:
as we raise and error when True. I'll update now

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👋 Should these kinds of validations occur in the client, e.g. should these validations occur here and in the API?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd agree with @sgerrand that we've generally avoided any sort of explicit type checking in the client and only performed basic consistency checks (i.e. that there are non-zero elements or certain attributes exist).

@JamesWair JamesWair marked this pull request as ready for review January 24, 2023 18:17
@JamesWair JamesWair requested a review from a team as a code owner January 24, 2023 18:17
Copy link
Contributor

@cianyleow cianyleow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I can see the value in having the int check to guide developers to using the correct numeric type.

We do perform this validation on the server side as well (passing in a float results in an error), so this is valid, but we should aim to roll this out consistently in the future.

@cianyleow cianyleow merged commit 922fd8a into main Jan 25, 2023
@cianyleow cianyleow deleted the OfferRequest-max-connections branch January 25, 2023 11:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants